<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>颜色_第2种表示_rgb或rgba</title>
    <style>
      .atguigu1 {
        color: rgb(255, 0, 255);
      }

      .atguigu2 {
        color: rgb(138, 43, 226);
      }

      /* aplha透明度 0.3 */
      .atguigu3 {
        color: rgba(255, 134, 219, 0.3);
      }
    </style>
  </head>
  <body>
    <h2 class="atguigu1">尚硅谷</h2>
    <h2 class="atguigu2">尚硅谷</h2>
    <h2 class="atguigu3">尚硅谷</h2>
    <span>www.baidu.com</span>
  </body>
</html>
<script>
  let randHexColor = Math.random().toString().substring(2, 8);
  document.querySelector("span").style.color = "#" + randHexColor;
</script>
